﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
using System.Web.Script.Services;
using EntitiesLayer.Entities;
using BusinnesLayer.LogicBusiness;

namespace ClinicaSanPablo
{
    public partial class MantenimientoCorreo : System.Web.UI.Page
    {
        private static Combosbl ptb = new Combosbl();
        private static System.Web.Script.Serialization.JavaScriptSerializer jsonSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();

        [WebMethod]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public static string ComboCorreo()
        {
            List<Combos> getCorreo = ptb.GetAllComboCorreo();
            return jsonSerializer.Serialize(getCorreo);
        }

         [WebMethod]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public static string UpdateCorreo(string CodTipoCorreo, string TxtTituloCorreo, string TxtDetalleCorreo, string Usuactualiza)
        {
            try
            {
                Mantenimientosbl tdbl = new Mantenimientosbl();

                Mantenimientos td = new Mantenimientos
                {
                    CodTipCorreo = CodTipoCorreo,
                    TituloCorreo = TxtTituloCorreo,
                    DetalleCorreo = TxtDetalleCorreo,
                    UsuarioActCorreo = Usuactualiza,
                    FechaActCorreo = Convert.ToDateTime(DateTime.Now.ToShortDateString()),
                };
                tdbl.UpdateCorreo(td);

                var data = new
                {
                    resultado = true
                };
                return jsonSerializer.Serialize(data);
            }
            catch (Exception ex)
            {
                var data = new
                {
                    resultado = false
                };
                return jsonSerializer.Serialize(data);
            }

        }

        protected void Page_Load(object sender, EventArgs e)
        {
            LblUsuarioSesion.Value = Session["Nombres"].ToString();
        }
    }
}